﻿namespace Stickam_Client
{
    [DesignerGenerated]
    public __gc class Form_Message : public Form
    {
        // Methods
        [DebuggerNonUserCode]
        public: Form_Message()
        {
            base->FormClosing += new FormClosingEventHandler __gc*(this.Form_Message_FormClosing);
            base->Load += new EventHandler __gc*(this.Form_Message_Load);
            this->InitializeComponent();
        }

        private: void __gc* AddFontText(String __gc* Msg, String __gc* font, String __gc* fontColor, Int32 __gc* fontSize, Boolean __gc* isBold, Boolean __gc* isItalics, Boolean __gc* isUnderline, Boolean __gc* newLine)
        {
            Int32 __gc* num = 0;
            if (isBold)
            {
                num++;
            }
            if (isItalics)
            {
                num += 2;
            }
            if (isUnderline)
            {
                num += 4;
            }
            if (newLine && (this->PrivateChat->TextLength > 0))
            {
                Msg = String::Concat(S"\r\n", Msg);
            }
            this->AddRichText(Msg, __gc new Font(font, *static_cast<__box Single*>((fontSize - 3)), *static_cast<__box FontStyle*>(num)), Globals::ColorFromString(fontColor));
        }

        private: void __gc* AddRichText(String __gc* Msg, Font __gc* FontType, Color __gc* FontColor)
        {
            this->PrivateChat->SelectionColor = FontColor;
            this->PrivateChat->SelectionFont = FontType;
            this->PrivateChat->AppendText(Msg);
        }

        private: void __gc* ChatInput_KeyPress(Object __gc* sender, KeyPressEventArgs __gc* e)
        {
            if (Strings::Asc(e->KeyChar) == 13)
            {
                e->Handled = true;
                String __gc* msg = Strings::Replace(this->ChatInput->Text, S"\r\n", S"\r", 1, -1, CompareMethod::Binary);
                this->ChatInput->Clear();
                this->AddFontText(String::Concat(this->MyScreenName, S": "), S"Arial", MySettingsProperty::Settings->FontColor, 12, false, false, false, true);
                this->AddFontText(msg, MySettingsProperty::Settings->FontFamily, MySettingsProperty::Settings->FontColor, MySettingsProperty::Settings->FontSize, MySettingsProperty::Settings->FontBold, MySettingsProperty::Settings->FontItalics, MySettingsProperty::Settings->FontUnderline, false);
                this->FormParent->SendPrivateMessage(this->Form_userID, msg);
            }
        }

        [DebuggerNonUserCode]
        protected: override void __gc* Dispose(Boolean __gc* disposing)
        {
            try
            {
                if (disposing && (this->components != 0))
                {
                    this->components->Dispose();
                }
            }
            finally
            {
                base->Dispose(disposing);
            }
        }

        private: void __gc* FontUpdated()
        {
            Int32 __gc* num = 0;
            if (MySettingsProperty::Settings->FontBold)
            {
                num++;
            }
            if (MySettingsProperty::Settings->FontItalics)
            {
                num += 2;
            }
            if (MySettingsProperty::Settings->FontUnderline)
            {
                num += 4;
            }
            this->ChatInput->Font = __gc new Font(MySettingsProperty::Settings->FontFamily, *static_cast<__box Single*>((MySettingsProperty::Settings->FontSize - 3)), *static_cast<__box FontStyle*>(num));
            this->ChatInput->ForeColor = Globals::ColorFromString(MySettingsProperty::Settings->FontColor);
        }

        private: void __gc* Form_Message_FormClosing(Object __gc* sender, FormClosingEventArgs __gc* e)
        {
            this->FormParent->RemovePrivateMessage(this->Form_userID);
            this->Form_userID = S"";
        }

        private: void __gc* Form_Message_Load(Object __gc* sender, EventArgs __gc* e)
        {
            this->FontUpdated();
        }

        [DebuggerStepThrough]
        private: void __gc* InitializeComponent()
        {
            ComponentResourceManager __gc* manager = __gc new ComponentResourceManager(__typeof(Form_Message));
            this->SplitContainer1 = __gc new SplitContainer();
            this->PrivateChat = __gc new RichTextBox();
            this->ChatInput = __gc new TextBox();
            this->SplitContainer1->Panel1->SuspendLayout();
            this->SplitContainer1->Panel2->SuspendLayout();
            this->SplitContainer1->SuspendLayout();
            this->SuspendLayout();
            this->SplitContainer1->Dock = DockStyle::Fill;
            this->SplitContainer1->IsSplitterFixed = true;
            Point __gc* point = (0, 0);
            this->SplitContainer1->Location = point;
            this->SplitContainer1->Name = S"SplitContainer1";
            this->SplitContainer1->Orientation = Orientation::Horizontal;
            this->SplitContainer1->Panel1->Controls->Add(this->PrivateChat);
            this->SplitContainer1->Panel2->Controls->Add(this->ChatInput);
            this->SplitContainer1->Panel2MinSize = 0x23;
            Size __gc* size = (0xd1, 0x7e);
            this->SplitContainer1->Size = size;
            this->SplitContainer1->SplitterDistance = 0x56;
            this->SplitContainer1->SplitterWidth = 1;
            this->SplitContainer1->TabIndex = 0;
            this->PrivateChat->Dock = DockStyle::Fill;
            this->PrivateChat->HideSelection = false;
            point = (0, 0);
            this->PrivateChat->Location = point;
            this->PrivateChat->Name = S"PrivateChat";
            this->PrivateChat->ScrollBars = RichTextBoxScrollBars::ForcedVertical;
            size = (0xd1, 0x56);
            this->PrivateChat->Size = size;
            this->PrivateChat->TabIndex = 0;
            this->PrivateChat->Text = S"";
            this->ChatInput->Dock = DockStyle::Fill;
            point = (0, 0);
            this->ChatInput->Location = point;
            this->ChatInput->Multiline = true;
            this->ChatInput->Name = S"ChatInput";
            size = (0xd1, 0x27);
            this->ChatInput->Size = size;
            this->ChatInput->TabIndex = 0;
            SizeF __gc* ef = (6, 13);
            this->AutoScaleDimensions = ef;
            this->AutoScaleMode = AutoScaleMode::Font;
            size = (0xd1, 0x7e);
            this->ClientSize = size;
            this->Controls->Add(this->SplitContainer1);
            this->FormBorderStyle = FormBorderStyle::SizableToolWindow;
            this->Icon = *static_cast<__box Icon*>(manager->GetObject(S"$this.Icon"));
            this->Name = S"Form_Message";
            this->StartPosition = FormStartPosition::Manual;
            this->Text = S"Private Message";
            this->SplitContainer1->Panel1->ResumeLayout(false);
            this->SplitContainer1->Panel2->ResumeLayout(false);
            this->SplitContainer1->Panel2->PerformLayout();
            this->SplitContainer1->ResumeLayout(false);
            this->ResumeLayout(false);
        }

        private: void __gc* NewPrivateMessage(String __gc* userID, String __gc* msg, String __gc* font, String __gc* fontColor, Int32 __gc* fontSize, Boolean __gc* isBold, Boolean __gc* isItalics, Boolean __gc* isUnderline)
        {
            if (this->Form_userID == userID)
            {
                this->AddFontText(Conversions::ToString(Operators::AddObject(this->FormParent->Userlist->getParam(userID, this->FormParent->Userlist->screenName), S": ")), S"Arial", fontColor, 12, false, false, false, true);
                this->AddFontText(msg, font, fontColor, fontSize, isBold, isItalics, isUnderline, false);
            }
        }


        // Properties
        [DebuggerNonUserCode]
        public private: __property virtual TextBox __gc* get_ChatInput()
        {
            return this->_ChatInput;
        }
        [MethodImpl(MethodImplOptions::Synchronized), DebuggerNonUserCode]
        public private: __property virtual void __gc* set_ChatInput(TextBox __gc* WithEventsValue)
        {
            KeyPressEventHandler __gc* handler = new KeyPressEventHandler __gc*(this.ChatInput_KeyPress);
            if (this->_ChatInput != 0)
            {
                this->_ChatInput->KeyPress -= handler;
            }
            this->_ChatInput = WithEventsValue;
            if (this->_ChatInput != 0)
            {
                this->_ChatInput->KeyPress += handler;
            }
        }

        [DebuggerNonUserCode]
        public: __property virtual Form1 __gc* get_FormParent()
        {
            return this->_FormParent;
        }
        [MethodImpl(MethodImplOptions::Synchronized), DebuggerNonUserCode]
        public: __property virtual void __gc* set_FormParent(Form1 __gc* WithEventsValue)
        {
            NewPrivateMessageEventHandler __gc* handler = new NewPrivateMessageEventHandler __gc*(this.NewPrivateMessage);
            FontUpdatedEventHandler __gc* handler2 = new FontUpdatedEventHandler __gc*(this.FontUpdated);
            if (this->_FormParent != 0)
            {
                this->_FormParent->NewPrivateMessage -= handler;
                this->_FormParent->FontUpdated -= handler2;
            }
            this->_FormParent = WithEventsValue;
            if (this->_FormParent != 0)
            {
                this->_FormParent->NewPrivateMessage += handler;
                this->_FormParent->FontUpdated += handler2;
            }
        }

        [DebuggerNonUserCode]
        public private: __property virtual RichTextBox __gc* get_PrivateChat()
        {
            return this->_PrivateChat;
        }
        [MethodImpl(MethodImplOptions::Synchronized), DebuggerNonUserCode]
        public private: __property virtual void __gc* set_PrivateChat(RichTextBox __gc* WithEventsValue)
        {
            this->_PrivateChat = WithEventsValue;
        }

        [DebuggerNonUserCode]
        public private: __property virtual SplitContainer __gc* get_SplitContainer1()
        {
            return this->_SplitContainer1;
        }
        [MethodImpl(MethodImplOptions::Synchronized), DebuggerNonUserCode]
        public private: __property virtual void __gc* set_SplitContainer1(SplitContainer __gc* WithEventsValue)
        {
            this->_SplitContainer1 = WithEventsValue;
        }


        // Fields
        [AccessedThroughProperty(S"ChatInput")]
        private: TextBox __gc* _ChatInput;
        [AccessedThroughProperty(S"FormParent")]
        private: Form1 __gc* _FormParent;
        [AccessedThroughProperty(S"PrivateChat")]
        private: RichTextBox __gc* _PrivateChat;
        [AccessedThroughProperty(S"SplitContainer1")]
        private: SplitContainer __gc* _SplitContainer1;
        private: IContainer __gc* components;
        public: String __gc* Form_userID;
        public: String __gc* MyScreenName;
    };
}

